local tianmengyvxin = fk.CreateSkill({
  name = "tianmengyvxin",
  tags = { Skill.Limited },
})

Fk:loadTranslationTable{
  ["tianmengyvxin"] = "甜梦愈心",
  [":tianmengyvxin"] = "限定技，当你进入濒死状态时，你可以将体力值恢复至最大体力值。",
}
-- 濒死触发效果
tianmengyvxin:addEffect(fk.EnterDying, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(tianmengyvxin.name) and 
      player:usedSkillTimes(tianmengyvxin.name, Player.HistoryGame) == 0 and
      player.maxHp > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player:isWounded() then
      room:recover { 
        num = player.maxHp - player.hp, 
        skillName = tianmengyvxin.name, 
        who = player, 
        recoverBy = player 
      }
    end
    
    if player.dead then return end
  end,
})

return tianmengyvxin